<?php

// 完善基本信息
// PUT base.complete

namespace app\api\resource\base;
use think\Db;

class Complete
{
    // 方法
    public $_method = ['PUT'];
    // 前置
    public $_pre    = ['adminLogin'];
    // 描述
    public $_description = '完善基本信息';
    // 参数
    public $_param  = [
        'email'   => '邮箱',
        'phone1'  => '电话1',
        'phone2'  => '电话2',
        'address' => '地址',
        'url'     => '网址',
        'record'  => '备案号',
    ];
    // 返回
    public $_return = [
        201 => '完善成功',
        500 => '服务器错误',
    ];

    public function run(&$request)
    {
        $params['email']   = $request->put('email/s','','trim');
        $params['phone1']  = $request->put('phone1/s','','trim');
        $params['phone2']  = $request->put('phone2/s','','trim');
        $params['address'] = $request->put('address/s','','trim');
        $params['url']     = $request->put('url/s','','trim');
        $params['record']  = $request->put('record/s','','trim');

        $num = Db::name('base')->where('id',1)->update($params);

        return ($num >= 0) ? [ 201,[] ] : 500;
    }
}